const arr = [4, 9, 2, 8, 1, 3, 6];
const newArr = [];

for (let i = 0; i < arr.length; i++) {
  newArr[arr[i]] = arr[i];
}

newArr.forEach((v) => console.log(v));
